package com.yzs.exam.entity.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @author yzs
 * @create 2021-04-20 22:08
 */
public enum QuestionTypeSuggestTimeEnum {
    SingleChoice(1, 2,"单选题"),
    MultipleChoice(2, 4, "多选题"),
    TrueFalse(3, 2,"判断题"),
    GapFilling(4, 8,"填空题"),
    ShortAnswer(5, 4,"简答题");

    int code;
    int suggestTime;//时间来着
    String name;

    QuestionTypeSuggestTimeEnum(int code, int suggestTime, String name) {
        this.code = code;
        this.suggestTime = suggestTime;
        this.name = name;
    }

    private static final Map<Integer, QuestionTypeSuggestTimeEnum> keyMap = new HashMap<>();

    static {
        for (QuestionTypeSuggestTimeEnum item : QuestionTypeSuggestTimeEnum.values()) {
            keyMap.put(item.getCode(), item);
        }
    }

    /**
     * 获取题目类型
     * @param code
     * @return
     */
    public static QuestionTypeSuggestTimeEnum fromCode(Integer code) {
        return keyMap.get(code);
    }


    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public int getSuggestTime() {
        return suggestTime;
    }

    public void setSuggestTime(int suggestTime) {
        this.suggestTime = suggestTime;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
